<?php

namespace AppBundle\Services;

use Psr\Log\LoggerInterface;

/**
 * Description of BaseService
 *
 * @author yihao
 */
class BaseService
{

    /**
     * @var LoggerInterface
     */
    private $logger;

    public function setLogger(LoggerInterface $logger)
    {
        $this->logger = $logger;
    }

    /**
     * @return LoggerInterface
     */
    public function getLogger()
    {
        return $this->logger;
    }

    protected function logDebug($message, array $context = array())
    {
        if ($this->logger) {
            $this->logger->debug($message, $context);
        }
    }

    protected function logInfo($message, array $context = array())
    {
        if ($this->logger) {
            $this->logger->info($message, $context);
        }
    }

    protected function logNotice($message, array $context = array())
    {
        if ($this->logger) {
            $this->logger->notice($message, $context);
        }
    }

    protected function logWarning($message, array $context = array())
    {
        if ($this->logger) {
            $this->logger->warning($message, $context);
        }
    }

    protected function logError($message, array $context = array())
    {
        if ($this->logger) {
            $this->logger->error($message, $context);
        }
    }

    protected function logCritical($message, array $context = array())
    {
        if ($this->logger) {
            $this->logger->critical($message, $context);
        }
    }

    protected function logAlert($message, array $context = array())
    {
        if ($this->logger) {
            $this->logger->alert($message, $context);
        }
    }

    protected function logEmergency($message, array $context = array())
    {
        if ($this->logger) {
            $this->logger->emergency($message, $context);
        }
    }

}
